/*
 * Integer.h
 *
 *  Created on: 2012-5-17
 *      Author: esf
 */

#ifndef INTEGER_H_
#define INTEGER_H_

#include "Object.h"
#include "String.h"
#include "Number.h"
#include <iostream>
#include <sstream>
namespace java_lang {

class Integer: public java_lang::Number,public virtual java_lang::Comparable<Integer> {
int value;
public:
	static const int MAX_VALUE=0x7fffffff;
	static const int MIN_VALUE=0x80000000;
	Integer();
	Integer(int);
	Integer(const Integer &i)
	{

		this->value=i.value;
	}
	int compareTo(Integer& o)
	{
		return this->value-o.value;
	}
	int valueOf();
	std::string toString();
	static Integer parseInt(std::string str)
		{
			std::stringstream ss;
			ss<<str<<'\0';
			int i;
			ss>>i;
			if(!(ss.good()))
			{
				return null;
			}
			else
			{
				Integer ii(i);
				return ii;
			}
		}
	int intValue(){return this->value;};
	int longValue(){return (long)value;};
	int floatValue(){return (float)value;};
	int doubleValue(){return (double)value;};
	static Integer parseInt(java_lang::String& string)
	{
		return parseInt(string.toString());
	}
	friend std::ostream & operator <<(std::ostream& out,const Integer & num)
	{
		out<<num.value;
		return out;
	}
	virtual ~Integer();

};

} /* namespace collection */
#endif /* INTEGER_H_ */
